/**
 * 
 */
package com.ra.landlord;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.googlecode.cswish.annotation.Rest;
import com.googlecode.cswish.struts.spring.GenericService;

/**
 * 房间资源
 * @author colin
 * @date 2014年9月14日
 */
@Service
public class RoomItemCfgService {
	
	@Resource
	private GenericService genericService;
	
	@Resource
	private LandlordUserService landlordUserService;
	
	/**
	 * 查询房间资源列表(逻辑是否要修改,目前APP的房间资源列表是通过Room.config实现的)
	 * @param model
	 * @return
	 */
	@Rest(type = "search")
	public List<RoomItemCfg> searchRoomItemCfg(){
		
		RoomItemCfg model = new RoomItemCfg();
		LandlordUser landlordUser = landlordUserService.getLoginUser();
		model.setLandlordUser(landlordUser.getOwnerUser());
		List<RoomItemCfg> lstRoomItemCfg = genericService.searchAll(model).getData();
		//52201用户的数据作为房间配置常量
		LandlordOwnerUser landlordOwnerUser = new LandlordOwnerUser();
		landlordOwnerUser.setId(52201);
		model.setLandlordUser(landlordOwnerUser);
		List<RoomItemCfg> lstRoomItemCfgConstant = genericService.searchAll(model).getData();
		
		if (lstRoomItemCfg != null && landlordUser.getOwnerUser().getId() != 52201) {
			lstRoomItemCfg.addAll(lstRoomItemCfgConstant);
		}else{
			lstRoomItemCfg = lstRoomItemCfgConstant;
		}
			
		return lstRoomItemCfg;
	}
	
}
